<template>
	<view>
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">防火巡查</block>
		</cu-custom>
		<!-- 顶部卡 -->
		<view class="padding-sm">
			<view class="radius shadow shadow-lg bg-white">
				<view class="detail">
					<view class="top">
						<view>
							<text>巡查对象：</text>
							<text>2楼xx巡查点</text>
						</view>
						<view>
							<text>本月累计巡查：</text>
							<text>x次</text>
						</view>
					</view>
					<view class="bottom">
						根据后台配置根据后台配置根据后台配置根据后台配置根据后台配置根据后台配置根据后台配置根据后台配置根据后台配置根据后台配置
					</view>					
				</view>
			</view>
		</view>
		<view class="result">
			<view class="top">巡查结果</view>
			<view class="normal">
				<radio-group name="checked">
					<label>
						<radio style="transform:scale(0.7)" :checked="normal"/><text>合格</text>
					</label>
					<label>
						<radio style="transform:scale(0.7)" :checked="!normal"/><text>不合格</text>
					</label>
				</radio-group>
			</view>
		</view>
		<view class="remarks">
			<view class="remarks-tp">巡查备注</view>
			<view class="inner">
				<textarea value="" placeholder="请描述此消防设施完好程度" />
			</view>
		</view>
		
		<view class="cu-bar bg-white margin-top">
			<view class="action">
				图片上传
			</view>
			<view class="action">
				{{imgList.length}}/4
			</view>
		</view>
		
		<view class="cu-form-group cu-form-groupss">
			<view class="grid col-4 grid-square flex-sub">
				<view class="bg-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" :data-url="imgList[index]">
				 <image :src="imgList[index]" mode="aspectFill"></image>
					<view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="index">
						<text class='cuIcon-close'></text>
					</view>
				</view>
				<view class="solids" @tap="ChooseImage" v-if="imgList.length<4">
					<text class='cuIcon-cameraadd'></text>
				</view>
			</view>
		</view>
		<view class="submit">
			<button type="primary" @click="submit">提交</button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				normal:true,
				checked:true,
				imgList: [],
			}
		},
		methods: {
			submit(){
				uni.navigateTo({
					url:'./result'
				})
			},
			ViewImage(e) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			ChooseImage() {
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						if (this.imgList.length != 0) {
							this.imgList = this.imgList.concat(res.tempFilePaths)
						} else {
							this.imgList = res.tempFilePaths
						}
					}
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.detail{
		padding:20rpx 12rpx;
		font-size:34rpx;
		.top{
			padding:12rpx 20rpx;
			border-bottom: 1rpx solid #AAAAAA;
		}
	}
	.bottom{
		padding: 20rpx;
	}
	
	.hydrant{
		.hydrant-bottom{
			display: flex;
			justify-content:flex-start;
			align-items: center;
			flex-wrap: wrap;
			view{
				display: flex;
				justify-content: flex-start;
				width: 20%;
			}
		}
	}
	.extinguisher{
		margin-top:12rpx;
		.type{
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		.portable{
			display: flex;
			align-items: center;
		}
		.inner{
			flex: 1;
			text-align: center;
		}
		.width{
			width: 140rpx;
			text-align: center;
		}
		.left{
			width: 180rpx;
		}
	}
	.other{
		margin-top:12rpx;
	}
	.other-bottom>text:nth-child(1){
		margin-right: 40rpx;
	}
	.radius{
		border-radius:12rpx;
	}
	.normal{
			display: flex;
			height: 100rpx;
			align-items: center;
			padding: 0 100rpx;
			uni-radio-group{
				width: 100%;
				display: flex;
				uni-label{
					flex: 1;
				}
			}
		}
	.result{
		background-color: #FFFFFF;
		padding: 20rpx 30rpx;
	}
	.remarks{
		margin-top:12rpx;
		padding:30rpx;
		background-color: #FFFFFF;
		textarea{
			padding:15rpx;
			border-radius:10rpx;
			border: 1rpx solid #AAAAAA;
			width: 100%;
		}
		.remarks-tp{
			margin-bottom:12rpx;
		}
		.inner{
			display: flex;
			justify-content: center;
		}
	}
	.solids{
		font-size: 50rpx;
	}
	.submit{
		margin:30rpx 40rpx;
	}
</style>
